package com.difsonapps.contacttranslator.utils;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.Namespace;
import org.jdom2.input.SAXBuilder;
import org.springframework.transaction.annotation.Transactional;


public class UtilGenerator {
  

	
	public static List<DTOElement> getAttributs(Element complexTypeElement) {
		List<DTOElement> dTOElements = new ArrayList<DTOElement>();
		
		List<Element> listOfElement = complexTypeElement.getChildren("xs:element");
		for(Element element : listOfElement)
		{
			dTOElements.add(new DTOElement(element.getAttributeValue("name"),element.getAttributeValue("type")));
		}
		
		return dTOElements;
	}
	
	public static String firstToUpper(String myString)
	{
		char[] stringArray = myString.toCharArray();
		stringArray[0] = Character.toUpperCase(stringArray[0]);
		myString = new String(stringArray);
		return myString;
	}
	public static String firstToLower(String myString)
	{
		char[] stringArray = myString.toCharArray();
		stringArray[0] = Character.toLowerCase(stringArray[0]);
		myString = new String(stringArray);
		return myString;
	}
	
	public static String dtoToDAO(String myString)
	{
		 myString = myString.replaceAll("DTO","DAO");
		return myString;
	}
	public static String dtoToService(String myString)
	{
		 myString = myString.replaceAll("DTO","Service");
		return myString;
	}
	
	public static boolean containt(String myString,String exp)
	{
		CharSequence cs = exp;
		 boolean result = myString.contains(cs);
		return result;
	}
	
	public static String dAOPath(String myString)
	{
		 myString = myString.replaceAll("DTO","DAO");
		 String path = "src/main/java/com/diffogroup/contacttranslator/dao/"+myString+".java";
		return path;
	}
	
	public static String servicePath(String myString)
	{
		 myString = myString.replaceAll("DTO","Service");
		 String path = "src/main/java/com/diffogroup/contacttranslator/service/itf/"+myString+".java";
		return path;
	}
	
	public static String serviceImplPath(String myString)
	{
		 myString = myString.replaceAll("DTO","Service");
		 String path = "src/main/java/com/diffogroup/contacttranslator/service/impl/"+myString+"Impl.java";
		return path;
	}
	
	
	
	
}
